<?php
/**
 * 회원 관련 model
 * 
 * @author gudals
 * @since 2013-07-25
 */

class modelContUserInfo extends modelContBase
{
    /**
     * 회원 추가
     * 
     * @param array $aReq 회원정보
     * @return Ambigous <NULL, multitype:void , void, unknown>
     */
    public function addUser($aReq)
    {
        $sQuery = "
            insert into bf_user_info (
                user_id,
                user_pwd,
                user_name,
                reg_ip,
                reg_ts
            ) values (
                '".$aReq['user_id']."',
                '".$aReq['user_pwd']."',
                '".$aReq['user_name']."',
                '".$_SERVER['REMOTE_ADDR']."',
                UNIX_TIMESTAMP()
            )
        ";
        
        return $this->executeQuery($sQuery, 'exec');
    }
    
    public function getInfoBySignin($sUserId, $sUserPwd)
    {
        if (chkTypesVariable(array('string' => $sUserId, 'string' => $sUserPwd)) === false) 
            return false;
        
        $sQuery = "
            select
                user_num,
                user_id,
                user_name,
                user_photo
            from
                bf_user_info
            where
                user_id = '".$sUserId."'
            and
                user_pwd = '".$sUserPwd."'
        ";
        
        return $this->executeQuery($sQuery, 'row');
    }
    
    /**
     * 유저 정보 수정
     * 
     * @param array $aReq
     * @return Ambigous <NULL, multitype:void , void, unknown>
     */
    public function modUserPhoto($aReq)
    {
        $sQuery = "
            update
                bf_user_info
            set
                user_photo = '".$aReq['file_name']."'
            where
                user_num = '".$aReq['user_num']."'
        ";
        
        return $this->executeQuery($sQuery, 'exec');
    }
    
    /**
     * 유저 정보
     * 
     * @param int $iUserNum 유저번호
     * @return boolean|Ambigous <NULL, multitype:void , void, unknown>
     */
    public function getInfo($iUserNum)
    {
        if (chkTypesVariable(array('int' => $iUserNum)) === false)
            return false;
        
        $sQuery = "
            select
                user_num,
                user_id,
                user_name,
                user_photo
            from
                bf_user_info
            where
                user_num = '".$iUserNum."'
        ";
        
        return $this->executeQuery($sQuery, 'row');
    }
    
    public function modUserInfo($aReq)
    {
        $aReq = addSlashesVariable($aReq, array('user_name'));
        
        $sQuery = "
            update
                bf_user_info
            set
                user_name = '".$aReq['user_name']."'
            where
                user_num = '".$aReq['user_num']."'
        ";
        
        return $this->executeQuery($sQuery, 'exec');
    }
    
    public function getInfoList($sUserNumList)
    {
        if (chkTypesVariable(array('string' => $sUserNumList)) === false)
            return false;
        
        $sQuery = "
            select
                user_num,
                user_id,
                user_name,
                user_photo
            from
                bf_user_info
            where
                user_num in (".$sUserNumList.")
        ";
        
        return $this->executeQuery($sQuery, 'rows');
    }
}